/**
 * Copyright (C), 2020, 安徽贝慕信息科技有限公司
 * FileName: DealerAppController
 * Author:   Allen
 * Date:     2020/8/27 17:10
 * Description: 商家应用接入号登记处理Controller
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bim.marvel.rest;

import com.bim.marvel.openapi.client.dto.DealerAppDTO;
import com.bim.marvel.openapi.client.query.DealerAppQuery;
import com.bim.marvel.openapi.client.query.PageQuery;
import com.bim.marvel.common.core.model.dto.SimplePageVO;
import com.bim.marvel.common.core.model.dto.SimpleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 〈商家应用接入号登记处理Controller〉
 *
 * @author Allen
 * @date 2020/8/27
 * @since 1.0.0
 */
@Api(tags = {"商家应用接入号登记处理-controller"})
@RequestMapping("/api/dealer/app")
public interface DealerAppController {

    /**
     * 保存商家应用接入号信息请求URL
     */
    String DEALER_APP_SAVE_URL = "/save";

    /**
     * 审核商家应用接入号信息请求URL
     */
    String DEALER_APP_REVIEW_URL = "/review/{appId}";
    /**
     * 商家应用接入号信息请求URL
     */
    String GET_DEALER_APP_URL = "/getByCompanyId/{companyCode}";
    /**
     * 商家应用接入号信息列表请求URL
     */
    String LIST_DEALER_APP_URL = "/list";

    /**
     * 保存商家应用接入号信息
     * @param dealerAppQuery 商家应用接入号信息入参
     * @return 保存状态
     */
    @ApiOperation(value = "保存商家应用接入号信息", notes = "保存商家应用接入号信息",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = DEALER_APP_SAVE_URL, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<Boolean> saveDealerApp(@Valid DealerAppQuery dealerAppQuery);

    /**
     * 审核商家应用接入号信息
     * @param appId 商家应用接入号入参
     * @return 审核结果
     */
    @ApiOperation(value = "审核商家应用接入号信息", notes = "审核商家应用接入号信息",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = DEALER_APP_REVIEW_URL, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<Boolean> reviewDealerApp(@ApiParam(name = "appId", value = "商家应用接入号")
                                      @PathVariable("appId") String appId);


    /**
     * 根据当前用户的企业编号获得该企业申请的商户接入号列表（无须分页）
     * @param companyCode 企业编号
     * @return 商户接入号列表
     */
    @ApiOperation(value = "根据商家编号查询该商家应用接入号列表信息", notes = "根据商家编号查询该商家应用接入号列表信息",
            protocols = "http,https", httpMethod = "GET")
    @GetMapping(value = GET_DEALER_APP_URL, produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<List<DealerAppDTO>> listDealerAppByCompanyCode(@ApiParam(name = "companyCode", value = "企业编号")
                                                            @PathVariable("companyCode") String companyCode);

    /**
     * 获得商家应用接入号信息列表
     * @param companyCode 企业编号
     * @param pageQuery 分页入参
     * @return 商家应用接入号信息列表
     */
    @ApiOperation(value = "获得商家应用接入号信息列表", notes = "获得后端开放API实体信息列表",
            protocols = "http,https", httpMethod = "GET")
    @GetMapping(value = LIST_DEALER_APP_URL, produces = {MediaType.APPLICATION_JSON_VALUE})
    SimplePageVO<List<DealerAppDTO>> listDealerApp(@ApiParam(name = "companyCode", value = "企业编号")
                                                   @RequestParam(value = "companyCode", required = false)
                                                            String companyCode, @Valid PageQuery pageQuery);

}
